package com.me.libgdx_test;

import com.badlogic.gdx.Game;

public class ActivityMain extends Game{
	
    ActivityGame gameScreen;
    ActivitySelection selectScreen;
    ActivityIndex indexScreen;
    ActivityEndScreen endScreen;
    ActivityMarketScreen marketScreen;
    ActivityGameInfo gameInfoScreen;
    ActivityError errorScreen;
    
    ClassReferenceDrawable game_vars;
	ClassUnlockables unlockable;
	ClassTexturePackerLoader sprite_textures;
	ClassSkinReference skin;
	ClassLogDisplay logger;
	
	InterfaceBilling billing;
	
	public ActivityMain(InterfaceBilling billing){
		this.billing = billing;
	}

   @Override
    public void create() {
	   //These objects are expensive and should only be made once. If I didn't have to worry about
	   //processing speed I would not make these global like this.
	   logger = new ClassLogDisplay("ActivityMain");
	   
	   logger.print("OnCreate");
	   
	   //This holds all the sprites. Used for easy reference
	   sprite_textures = new ClassTexturePackerLoader("data/all.txt","data/all.png",0, 
			   new ClassAnimationTextureLoader("data/animations.txt","data/animations.png",0));

	   //We are copying all the animation sprites here so that they can be referenced by the sprite texture class
	   unlockable = new ClassUnlockables("", this);
	   skin = new ClassSkinReference();
    }
   
   @Override
   public void resume(){
	   //You cannot call super.onResume(); Noted...
	   //super.resume();
   }
   
   @Override
   public void dispose()
   {
       super.dispose();

       if(gameScreen != null) gameScreen.dispose();
       if(selectScreen != null) selectScreen.dispose();
       if(indexScreen != null) indexScreen.dispose();
       if(endScreen != null) endScreen.dispose();
       if(marketScreen != null) marketScreen.dispose();
       if(gameInfoScreen != null) gameInfoScreen.dispose();
       if(errorScreen != null) errorScreen.dispose();
       
       skin.get_alternate_skin().dispose();
       skin.get_button_skin().dispose();
       skin.get_skin().dispose();
   }
   
   public void init_error(String error_string){
	   errorScreen = new ActivityError(this,error_string);
	   setScreen(errorScreen); 
   }
   
   public void init_activities(){
	   logger.print("init activities");
	   indexScreen = new ActivityIndex(this);   
	   logger.print("index");
	   selectScreen = new ActivitySelection(this);
	   logger.print("selection");
	   try {
		   marketScreen = new ActivityMarketScreen(this);
		   logger.print("market");
		   gameInfoScreen = new ActivityGameInfo(this);
		   logger.print("Setting Screen!");
	   } catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
	   }
	   setScreen(indexScreen); 
	   logger.print("end init");
   }
   
   //This is for when things are bought at the store 
   //so that we dont have to call each method individually
   public void reset_activities(){
	   selectScreen.init_things();
	   gameInfoScreen.init_things();
   }
}